package com.yeung.exam;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import static java.lang.System.exit;

public class 讯飞_用户验证 {
    public static void main(String[] args) {
        System.out.println((int)'a');
        System.out.println((int)'z');
        System.out.println((int)'A');
        System.out.println((int)'Z');
        exit(0);
        int n = 3;
        List<String> exitsName = new ArrayList<>();
        exitsName.add("zhangsan");
        exitsName.add("lisi");

        Scanner sc = new Scanner(System.in);
        List<String> input = new ArrayList<>();
        while (n > 0) {
            input.add(sc.nextLine());
            n--;
        }
        User nu = new User(input.get(0), input.get(1), input.get(2));
        //
        //先判断用户名
        if (exitsName.contains(nu.name)) {
            System.out.println("该用户名已存在");
            return;
        }
        if (!validPsw(nu.pass)) {
            System.out.println("密码格式错误");
            return;
        }
        if (!validPhone(nu.phone)) {
            System.out.println("请输入正确的手机号码");
            return;
        }
        System.out.println("注册成功");

    }

    public static boolean validPhone(String phone) {
        boolean flag = true;
        if (phone.length() != 11) flag = false;
        if (!phone.startsWith("1")) flag = false;
        return flag;
    }

    public static boolean validPsw(String psw) {
        boolean flag = true;
        if (psw.equals("")) flag = false;
//        if (psw.length() < 8 || psw.length() > 16) flag = false;
//        String regx="^[a-z0-9A-Z]+$";
        String regx="^[0-9A-Za-z]{8,16}";
        String regx2="!(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$";
        if(!psw.matches(regx)) flag=false;
        return flag;
    }

    static class User {
        String name;
        String pass;
        String phone;

        public User(String name, String psw, String phone) {
            this.name = name;
            this.pass = psw;
            this.phone = phone;
        }

        public User() {
        }
    }
}
